#pragma once

#include "fxcc/core/graph/common/ModelMetaCacheFile.h"
#include "fxcc/core/graph/common/Texture2DJack.h"
#include "fxcc/core/graph/common/Texture2DArrayJack.h"
#include "fxcc/core/graph/common/Texture3DJack.h"
#include "fxcc/core/graph/common/TextureCubeJack.h"
#include "fxcc/core/graph/common/TextureCubeArrayJack.h"

namespace fxcc::graph::common
{

	struct Texture2DMap
	{
		MetaMapIndex m_Index;
		std::shared_ptr<fxcc::graph::common::Texture2DJack> m_Value;
		bool OnLoad();
		ImTextureID GetTextureId() const
		{
			return m_Value ? m_Value->GetTextureId() : 0;
		}

	};
	struct TextureCubeMap
	{
		MetaMapIndex m_Index;
		std::shared_ptr<fxcc::graph::common::TextureCubeJack> m_Value;
		bool OnLoad();

	};
	struct Texture2DArrayMap
	{
		MetaMapIndex m_Index;
		std::shared_ptr<fxcc::graph::common::Texture2DArrayJack> m_Value;
		bool OnLoad();

	};
	struct TextureCubeArrayMap
	{
		MetaMapIndex m_Index;
		std::shared_ptr<fxcc::graph::common::TextureCubeArrayJack> m_Value;
		bool OnLoad();

	};
	struct Texture3DMap
	{
		MetaMapIndex m_Index;
		std::shared_ptr<fxcc::graph::common::Texture3DJack> m_Value;
		bool OnLoad();
	};

	struct IrradianceTextureMap
	{
		MetaMapIndex m_Index;
		std::shared_ptr<fxcc::graph::common::TextureCubeJack> m_Value;
		bool OnLoad();
	};

	struct PrefilterTextureMap
	{
		MetaMapIndex m_Index;
		std::shared_ptr<fxcc::graph::common::TextureCubeJack> m_Value;
		bool OnLoad();
	};


	struct BRDFTextureMap
	{
		MetaMapIndex m_Index;
		std::shared_ptr<fxcc::graph::common::Texture2DJack> m_Value;
		bool OnLoad();
		ImTextureID GetTextureId() const
		{
			return m_Value ? m_Value->GetTextureId() : 0;
		}
	};

	struct TextureMaps :public fxcc::Base
	{
		int m_GlslStartIndex{ 0 };

		std::map<std::string, Texture2DMap> m_Texture2Ds;

		std::map<std::string, Texture3DMap> m_Texture3Ds;

		std::map<std::string, Texture2DArrayMap> m_Texture2DArrays;

		std::map<std::string, TextureCubeMap> m_TextureCubes;

		std::map<std::string, TextureCubeArrayMap> m_TextureCubeArrays;
		
		bool OnLoad();

		bool SetTexture2D(const std::string& key, const std::string& realPath);

		bool SetTexture2DArray(const std::string& key, const std::string& realPath);

		bool SetTextureCube(const std::string& key, const std::string& realPath);

		bool SetTextureCubeArray(const std::string& key, const std::string& realPath);

		bool SetTexture3D(const std::string& key, const std::string& realPath);

		void InitTexture2D(const std::string& key);

		void InitTexture2DArray(const std::string& key);

		void InitTextureCube(const std::string& key);

		void InitTextureCubeArray(const std::string& key);

		void InitTexture3D(const std::string& key);

	};
}